package com.gome.ai.aiparter.even;

import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lww
 * @date 2020-04-09 18:05
 */
@Component
public class HelloController {

    @Resource
    private ApplicationContext context;

    @PostConstruct
    public void hello() {
        new Thread(() -> {
            while (true){
                try {
                    Thread.sleep(10000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }

                context.publishEvent(new MyApplicationEvent("发布事件啦"));
            }
        }).start();
    }

}